package com.cloud.workTest;

public class NotifyTest {
    public static void main(String[] args) {
        byte[] lock = new byte[0];

        Thread t1 = new Thread(() -> {
            synchronized (lock) {
                try {
                    System.out.println("Thread1 is start");
                    lock.wait();
                    System.out.println("Thread1 is end");
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        Thread t2 = new Thread(() -> {
            synchronized (lock) {
                try {
                    System.out.println("Thread2 is start");
                    lock.wait();
                    System.out.println("Thread2 is end");
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        Thread t3 = new Thread(() -> {
            synchronized (lock) {
                try {
                    System.out.println("Thread3 is start");
                    Thread.sleep(1000);
                    lock.notifyAll();
                    System.out.println("Thread3 has notify all");
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        t1.setPriority(1);
        t2.setPriority(3);
        t3.setPriority(2);

        t1.start();
        t2.start();
        t3.start();
    }
}
